<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        window.onbeforeunload    =    function(){

          if(self.screenTop > 9000)
           {
               alert("是关闭而非刷新");
               window.event.returnValue    =   "是否关闭？";
           }else{
                  alert("是刷新而非关闭");
          }
    }

    </script>
</head>
<body>
<h3>hello world</h3>
</body>
</html>